<%@page import="coredb.Queries" %>
<%@page import="java.util.Date" %>
<%@page import="java.util.List" %>
<%@page import="coredb.Account" %>
<%@page import="coredb.Transaction" %>
<%@page import="java.text.SimpleDateFormat" %>
<%@page import="java.text.ParseException" %>
<%@page errorPage="sorry.html" %>
<%
    response.setContentType("text/csv");
    Date d = new Date();
    response.setHeader("Content-Disposition", "inline;filename="+d.toString()+".csv");
%>
<%
    out.println("Account No,Transaction Id, Time of transaction, Amount, Type of transaction");
    Queries q = new Queries();
    List<Transaction> res = q.getDailyReport();
    for (Transaction t : res) {
        String typ = t.getTypeoftxn();
        String typeOfTxn = "DEPOSIT";
        if (typ.equals("W")) {
            typeOfTxn = "WITHDRAWL";
        }
        out.println(String.valueOf(t.getAccno().getAccno())+","+t.getTxnid()+","+String.valueOf(t.getTimeoftxn())+","+String.valueOf(t.getAmount())+","+typeOfTxn);
    }
    
%>